package com.tange.ai.iot.client.gnssa.view.popup;

import android.content.Context;
import android.os.CountDownTimer;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.ScreenUtils;
import com.tange.ai.iot.client.gnssa.R;

import razerdp.basepopup.BasePopupWindow;


/**
 * 说明：
 * Created by jjs on 2019/1/4
 */
public class NormalMsgHPopup extends BasePopupWindow {

    public TextView tvLeft;
    public TextView tvRight;
    public TextView tvTitle;
    public TextView tvContent;
    private CountDownTimer timer;

    public boolean isShowBottom;


    public NormalMsgHPopup(Context context) {
        super(context);
        this.setWidth((int) (ScreenUtils.getScreenWidth() * 0.7));
        setPopupGravity(Gravity.CENTER);
        tvLeft = findViewById(R.id.tv_left);
        tvRight = findViewById(R.id.tv_right);
        tvTitle = findViewById(R.id.tv_title);
        tvContent = findViewById(R.id.tv_content);

        tvLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public NormalMsgHPopup(Context context, boolean isShowBottom) {
        super(context);
        this.isShowBottom=isShowBottom;
        this.setWidth((int) (ScreenUtils.getScreenWidth() * 0.7));
        setPopupGravity(Gravity.CENTER);
        tvLeft = findViewById(R.id.tv_left);
        tvRight = findViewById(R.id.tv_right);
        tvTitle = findViewById(R.id.tv_title);
        tvContent = findViewById(R.id.tv_content);

        tvLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    @Override
    public void showPopupWindow() {
        if (isShowBottom) {
            showPopupWindow(ScreenUtils.getScreenWidth() / 2, (int) (ScreenUtils.getScreenHeight() * 1));
        } else {
            super.showPopupWindow();
        }
    }

    public NormalMsgHPopup setTitle(String title) {
        TextView tvTitle = findViewById(R.id.tv_title);
        tvTitle.setText(title);
        return this;
    }

    public NormalMsgHPopup setContent(String content) {
        TextView tvContent = findViewById(R.id.tv_content);
        tvContent.setText(content);
        return this;
    }

    public NormalMsgHPopup setLeftButtonText(String str) {
        TextView tv = findViewById(R.id.tv_left);
        tv.setText(str);
        return this;
    }

    public NormalMsgHPopup setRightButtonText(String str) {
        TextView tv = findViewById(R.id.tv_right);
        tv.setText(str);
        return this;
    }


    @Override
    public View onCreateContentView() {
        return createPopupById(com.tange.ai.iot.client.gnssa.R.layout.popup_normal_h_message);
    }
}
